package com.example.demo.service.serviceImpl;

import com.example.demo.vo.RedisModel;
import com.example.demo.service.RedisService;
import com.example.demo.utils.JsonResult;
import com.example.demo.utils.RedisUtil;
import com.example.demo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service(value = "redisService")
public class RedisServiceImpl implements RedisService {
    @Autowired
    private RedisUtil redisUtil;


    @Override
    public void addRedis(Object key,Object value) {
        redisUtil.setCacheObject(key,value);
    }

    @Override
    public void delRedis(Object key) {
        redisUtil.removeCache(key);
    }

    @Override
    public JsonResult getAllRedis() {
        List<RedisModel> allCache = redisUtil.getAllCache();
        return ResultUtil.success("查询成功",allCache);
    }
}
